const service = require("../server/index");
const path = require("path");

const LocalStorage = require("node-localstorage").LocalStorage;
localStorage = new LocalStorage("./scratch");


const getLogin = async (userInfo, code, id) => {
  try {
    const { email, password } = userInfo;
    let { data: res } = await service.post(
      "https://tongji-api.dcloud.net.cn/uni/stat/api/user/login",
      {
        email,
        password,
        code,
        id,
      }
    );
    if (res.token) {
      localStorage.setItem("token", res.token);
    }
    return res;
  } catch (e) {
    console.log(e);
  }
};

module.exports = getLogin;
